package track1;

public class Movie implements Runnable{

    static int ticket=100;
    @Override
    public void run() {
        while (true){
            synchronized (Movie.class){
                //判断票数
                if (ticket==0){
                    break;
                }
                try {
                    Thread.sleep(30);
                    ticket--;
                    System.out.println(Thread.currentThread().getName()+"还剩"+ticket+"张票");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
